package com.jscloud.bigdata.flink.connector;

import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.io.TextInputFormat;
import org.apache.flink.api.java.operators.DataSource;
import org.apache.flink.core.fs.Path;

import java.net.URI;

public class HDFSBatchByJava {
        public static void main(String[] args) throws Exception {
                //构建批量处理编程对象
                ExecutionEnvironment executionEnvironment = ExecutionEnvironment.getExecutionEnvironment();
                //定义读取数据路径
                Path path = new Path(new URI("hdfs://bigdata01:8020/path_dir"));
                TextInputFormat textInputFormat = new TextInputFormat(path);
                //通过调用createInput方法实现读取HDFS数据
                DataSource<String> inputBase = executionEnvironment.createInput(textInputFormat);
                inputBase.print();
        }
}